%% @author Carlos Abalde <carlos.abalde@gmail.com>
%% @doc    ...

%%%----------------------------------------------------------------------
%%%
%%% EMC, Copyright (C) 2009 Carlos Abalde
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%%
%%%----------------------------------------------------------------------

-module(emc.sup).
-behaviour(supervisor).

-import(supervisor).
-import(erlang).
-import(emc.util.util).

-export([start/0, init/1]).

%%
%%
%%
start() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).

%%
%%
%%
init([]) ->
    SupFlags = {one_for_all, 50, 60},
    {ok, {SupFlags, [ child(emc.util.logger, []),
		      child(emc.cpool, []) ]}}.

%%
child(Module, Args) ->
    {A,B,C} = erlang:now(),
    { util:a2a(util:a2l(Module) ++ "_" ++ util:a2l(A) ++ util:a2l(B) ++ util:a2l(C)),
      {Module, start_link, Args},
      permanent,
      2000,
      worker,
      [Module] }.
